package dk.bris.bean;

import java.io.Serializable;

import javax.faces.bean.ApplicationScoped;
import javax.faces.bean.ManagedBean;

@ManagedBean
@ApplicationScoped
public class QuickPollSetup implements Serializable {

	private static final long serialVersionUID = 1L;
	private String question;;
	private String vote;
	
	private int yes = 0;
	private int no = 0;
	
	private int total = 0;

	public String getVote() {
		return vote;
	}

	public void setVote(String vote) {
		if("yes".equals(vote)) {
			yes++;
		}
		else {
			no++;
		}
		total++;
	}

	public String getQuestion() {
		return question;
	}

	public void setQuestion(String question) {
		this.question = question;
	}
	
	public String setup() {
		if("".equals(question)){
			return "setup";
		}
		yes = 0; 
		no = 0; 
		total = 0;
		return "ask";
	}
	
	public int getTotal() {
		return total;
	}

	public void setTotal(int total) {
		this.total = total;
	}

	public int getYes() {
		return yes;
	}

	public void setYes(int yes) {
		this.yes = yes;
	}

	public int getNo() {
		return no;
	}

	public void setNo(int no) {
		this.no = no;
	}

	public void vote(String result) {
		if("yes".equals(result)){ 
			System.out.println("YES");
		}
		else if("no".equals(result)){ 
			System.out.println("NO");
		}
		else {
			System.out.println(result);
		}
	}
}
